<template type="text/x-template" id="publish">
    <div>
        <el-tooltip class="item" effect="dark" content="访问index.htm生成的首页，系统设置>模板管理通过上传模板来修改模板名称" placement="bottom">
            <el-link class="el-icon-orange" type="primary" @click="viewIndex()">预览网站</el-link>
        </el-tooltip>
        <el-tooltip class="item" effect="dark" content="发布网站后可以预览网站看到页面效果" placement="bottom">
            <el-link class="el-icon-video-play" type="primary" v-loading="publishLoading" style="margin: 0 20px" @click="publishSite()" :disabled="publishLoading">发布网站</el-link>
        </el-tooltip>
    </div>

</template>
<script>
    var Publish = Vue.defineComponent({
        template: '#publish',
        name: 'publish',
        props: {},
        data:function (){
            return {
                publishLoading:false,
            }
        },
        methods: {
            // 发布网站
            publishSite: function () {
                var that = this;
                that.publishLoading = true;
                that.$confirm("即将发布网站(中文模板必须为index.htm,英文模板必须为default.htm,生成位置同模板名称)", "提示", {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function () {
                    ms.http.get(ms.manager + '/cms/generate/publish.do').then(function (res) {
                        if (res.result) {
                            that.$notify({
                                type: 'success',
                                message: '网站发布成功，可点击预览网站查看网站页面',
                                title: '成功'
                            })
                        }else {
                            that.$notify({
                                type: 'error',
                                message: res.msg,
                                title: '失败'
                            })
                        }
                        that.publishLoading = false;

                    }).catch(function () {
                        that.$notify({
                            type: 'error',
                            message: '失败',
                            title: '失败'
                        })
                    })
                }).catch(function (){
                    that.publishLoading = false;
                })
            },
            //预览主页
            viewIndex: function () {
                window.open(ms.manager + "/cms/generate/index/viewIndex.do");
            },
        },
        created: function (){
        }
    })
</script>